<?php
 	ini_set("include_path", ".:../:./includes:../includes");
	session_start();
	extract($_REQUEST);
	require_once("includes/constants.php");
	require_once("includes/database.php");

	for ($i = 0; $i < DELIVERY_SERVICE_PRICE_COUNT; $i++) {
		$weight = $_REQUEST["dc_weight_limit_" . $i];
		$price = $_REQUEST["dc_price_" . $i];
		if (!($weight == "" || $price == "")) {
			$prices[$weight] = $price;
		}
	}

	if (updateShippingOption($selectedShippingOption, $ds_service_name ,$ds_max_width,$ds_max_height, $ds_max_length, 
		$ds_guaranteed, $ds_delivery_time, $ds_status, $prices) != 0) {
		$confirmationMessage = "$ds_service_name have been updated." ;
		$_SESSION[SHIPPING] =getAllShippingOptions(); //update shipping options list in session 
		header( 'Location: confirmationPage.php?' . "confirmationMessage=" .$confirmationMessage) ;
	}
	else {
		$errorMessage = "There has been a problem updating $ds_service_name.";
		header( 'Location: errorPage.php?' . "errorMessage=" . $errorMessage ) ;
	}	
	;

?>
